<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTasksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tasks', function (Blueprint $table) {
            $table->id();
            $table->string('name')->nullable(true)->comment('名称');
            $table->nullableMorphs('dev');
            $table->string('filepath')->nullable(true)->comment('文件路径');
            $table->string('status')->nullable(true)->comment('状态');
            $table->string('status_info')->nullable(true)->comment('执行状态(返回值)');
            $table->unsignedInteger('estimate')->nullable(true)->comment('预计时间');
            $table->integer('user_id')->comment('用户id');
            $table->string('remarks')->nullable(true)->comment('备注');
            $table->timestamps();
        });

        Schema::create('reports', function (Blueprint $table) {
            $table->id();
            $table->nullableMorphs('dev');
            $table->json('advice')->nullable(true)->comment('诊断建议(json)');
            $table->json('result')->nullable(true)->comment('诊断结果(json)');
            $table->integer('task_id')->nullable(false)->comment('任务id');
            $table->string('remarks')->nullable(true)->comment('备注');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('tasks');
        Schema::dropIfExists('reports');
    }
}
